﻿using cnBlogs.Common.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;

namespace cnBlogs.Common.Converter
{
    class TodayToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            string s = value.ToString().Remove(0, 3).Trim();
            DateTime dt = DateTime.Parse(s);
            TimeSpan ts = dt - LastAccessHelper.GetLastAccessTime();
            if (ts > TimeSpan.Zero)
            {
                return new SolidColorBrush(Colors.Yellow);
            }
            else
                return new SolidColorBrush(Colors.White);
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
